/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow-x: hidden;
}

/* Responsive container with iframe detection */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 10px;
    gap: 8px;
}

/* Detect if running in new tab (not iframe) */
@media screen and (min-height: 600px) {
    .container {
        height: 90vh;
        padding: 20px;
        gap: 15px;
    }
}

/* Control Panel Styles */
.control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    border: 2px solid #e9ecef;
    min-height: 50px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    min-width: 150px;
}

.control-group label {
    font-weight: 600;
    font-size: 12px;
    color: #495057;
    white-space: nowrap;
}

.control-select {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-select:hover {
    border-color: #80bdff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.start-btn {
    padding: 8px 16px;
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
    height: fit-content;
    white-space: nowrap;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.start-btn:active {
    transform: translateY(0);
}

/* Visualization Area - Modified to only contain graph */
.visualization-area {
    flex: 1;
    display: flex;
    gap: 10px;
    min-height: 250px;
}

/* Graph container - Now takes full width of visualization area */
.graph-container {
    flex: 1;
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#titration-graph {
    max-width: 100%;
    max-height: 100%;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

/* Information Panel */
.info-panel {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 10px;
    border: 2px solid #e9ecef;
    min-height: 80px;
}

.indicator-info h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #495057;
}

.indicator-details {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.indicator-range {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
}

.color-change {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-box {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #dee2e6;
    display: inline-block;
}

.arrow {
    font-size: 14px;
    color: #6c757d;
}

.suitability-indicator {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #dee2e6;
}

.suitability-text {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.explanation {
    font-size: 11px;
    color: #6c757d;
    line-height: 1.4;
}

/* Suitability status colors */
.suitable { color: #28a745; }
.unsuitable { color: #dc3545; }
.marginal { color: #ffc107; }

/* Tooltip Styles */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 250px;
    line-height: 1.4;
}

.tooltip.show {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .visualization-area {
        flex-direction: column;
        gap: 8px;
    }
    
    .control-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .control-group {
        min-width: auto;
    }
    
    .indicator-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .control-select, .start-btn {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .color-box {
        width: 24px;
        height: 24px;
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.pulse {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}